package com.hyk.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hyk.domain.AdminAddress;
import com.hyk.domain.Coin;
import com.hyk.mapper.AdminAddressMapper;
import com.hyk.service.AdminAddressService;
import com.hyk.service.CoinService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AdminAddressServiceImpl extends ServiceImpl<AdminAddressMapper, AdminAddress> implements AdminAddressService{

    @Resource
    private CoinService coinService;

    @Override
    public void saveNew(AdminAddress adminAddress) {
        Coin coin = coinService.getById(adminAddress.getCoinId());
        if(coin == null){
            throw new IllegalArgumentException("输入的币种id错误");
        }
        adminAddress.setCoinType(coin.getType());
        save(adminAddress);
    }
}
